# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Leo <thinkabit.ukim@gmail.com>
pkgname=imgbrd-grabber
pkgver=7.3.1
pkgrel=0
pkgdesc="Powerful imageboard/booru downloader"
options="!check" # Tests requires graphics
url="https://bionus.github.io/imgbrd-grabber"
# mps64 and mips64el blocked by nodejs restrictions
# armhf blocked by qt5-qtdeclarative
arch="all !mips64 !mips64el !armhf"
license="Apache-2.0"
makedepends="cmake nodejs qt5-qtdeclarative-dev qt5-qtmultimedia-dev
	qt5-qtbase-mysql qt5-qtbase-odbc qt5-qtbase-sqlite qt5-qtbase-tds
	qt5-qtscript-dev qt5-qtbase-dev qt5-qttools-dev npm"
source="$pkgname-$pkgver.tar.gz::https://github.com/Bionus/imgbrd-grabber/archive/v$pkgver.tar.gz"
builddir="$srcdir"/imgbrd-grabber-$pkgver/src

prepare() {
	default_prepare
	sed -i 's|USE_QSCINTILLA 1|USE_QSCINTILLA 0|' gui/CMakeLists.txt
	sed -i 's|USE_BREAKPAD 1|USE_BREAKPAD 0|' gui/CMakeLists.txt
	sed -i '/add_subdirectory(tests)/d' CMakeLists.txt
}

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DCMAKE_C_FLAGS="$CFLAGS" \
		$CMAKE_CROSSOPTS
	make -C build
}

package() {
	make -C build DESTDIR="$pkgdir" install
	touch "$pkgdir"/usr/share/Grabber/settings.ini
}

sha512sums="c543544d7ddd634c144a656dc95fcf9732f134f538c056071c4d6456601e374612d31a0e063b74728c1a200e5464e68500d47699e5634cd4d54ed7017d88eddb  imgbrd-grabber-7.3.1.tar.gz"
